
Partial Class CodeListing
    Inherits System.Web.UI.Page

    Protected Sub GridView1_RowDataBound(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.GridViewRowEventArgs) Handles GridView1.RowDataBound
        'Dim grd As GridView = CType(e.Row.FindControl("parameterList"), GridView)
        'If grd IsNot Nothing Then
        'Dim id As Integer = Convert.ToInt32(GridView1.DataKeys(e.Row.DataItemIndex).Value)
        'grd.DataSource = getDataSource(id)
        'grd.DataBind()
        'End If
    End Sub

    Private Function getDataSource(ByVal id As Integer) As SqlDataSource
        Dim sql As String = String.Format("select sc.name + ' ' + st.name as paramname from syscolumns sc, systypes st where sc.xtype=st.xtype and sc.id={0}  order by sc.colorder", id.ToString())
        Dim sqlds As New SqlDataSource(EntityController.AppConnectString, sql)
        Return sqlds
    End Function

    Private Function getTableDataSource(ByVal tableName As String) As SqlDataSource
        Dim sql As String = String.Format("select [Column Name], [Data Type], [Default],[Allow Nulls],[Identity] from vwTableList where Table_Name='{0}'  order by ordinal_position", tableName)
        Dim sqlds As New SqlDataSource(EntityController.AppConnectString, sql)
        Return sqlds

    End Function

    Protected Sub GridView2_RowDataBound(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.GridViewRowEventArgs) Handles GridView2.RowDataBound
        Dim grd As GridView = CType(e.Row.FindControl("parameterList"), GridView)
        If grd IsNot Nothing Then
            Dim tblName As String = Convert.ToString(GridView2.DataKeys(e.Row.DataItemIndex).Value)
            grd.DataSource = getTableDataSource(tblName)
            grd.DataBind()
        End If
    End Sub
End Class
